<%@ page import="com.tm.controller.InstrumentController" %>
<%@ page import="com.tm.pojo.Instrument" %>
<%@ page import="com.tm.controller.PriceController" %>
<%@ page import="com.tm.pojo.PriceDate" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="com.google.appengine.api.users.UserService" %>
<%@ page import="com.google.appengine.api.users.UserServiceFactory" %>

<jsp:include page="header.jsp"></jsp:include>

<%
InstrumentController ic = InstrumentController.getInstance();
Iterator<Instrument> instruments = ic.getInstruments().iterator();
PriceController pc = PriceController.getInstance();
%>
	
<table border="0" id="tblInstruments">
	<tr><th>Term</th><th>Name</th><th>Type</th><th>Bloomberg Id</th><th>Currency</th><th>Price Date</th><th>Price</th><th>Action</th></tr>
	<%
	while(instruments.hasNext()) {
		Instrument i = instruments.next();
	%>
		<tr id="row<%=i.getInstrumentId()%>">
			<td><%=i.getStrTerm()%></td>
			<td><%=i.getName()%></td>
			<td><%=i.getType()%></td>
			<td><%=i.getBloombergId()%></td>
			<td><%=i.getCurrency()%></td>
			<% 
				pc.setInstrumentId(i.getInstrumentId());
				PriceDate pd = pc.getLastPrice();
			%>
			<td><%=pd.getDate() %></td>
			<td><%=pd.getPrice() %></td>
			<td><a href="priceHistory.jsp?instrumentId=<%=i.getInstrumentId()%>">history</a></td>
		</tr>
	<%
	}
	%>
</table>

<jsp:include page="footer.jsp"></jsp:include>